#include "displaydetailsinterface.h"
#include "globaluserlist.h"
#include "userZZL.h"
#include "QTextEdit"

displaydetailsinterface::displaydetailsinterface(QString name, QWidget *parent)
    : QMainWindow{parent}
{
    this->informations = new QTextEdit(this);
    this->informations->setReadOnly(true);
    // 启用自动换行
    this->informations->setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);

    QTextEdit* board = this->informations;
    this->setMinimumSize(200, 300);
    board->setMinimumSize(200, 290);
    if (name[0] == 'u') {
        globaluserlist &glbuserlist = globaluserlist::getInstance();
        userZZL* u = glbuserlist.list[0];
        for (auto i: glbuserlist.list) {
            if (i->getUsername() == name) {
                u = i;
            }
        }
        board->setText("用户基本信息: \n");
        board->append("用户类型: " + QString(u->getNum_id() == 101 ? "微信用户": "QQ用户"));
        board->append("用户名: " + u->getUsername());
        board->append("所在地: " + u->getLocation());
        board->append("生日: " + u->getBthDay().toString("yyyy-MM-dd"));
        board->append("注册时间: " + u->getRgTime().toString("yyyy-MM-dd"));

    } else {
        board->setText("群组基本信息: \n");
        board->append("群组名: " + name);
        board->append("群成员: user1 user2 user5 user8");
    }
}

displaydetailsinterface::~displaydetailsinterface()
{
    ;;
}
